package com.koron.housing.contract.service;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.koron.bean.query.PageQuery;
import com.koron.housing.contract.bean.dto.HousingContractDTO;
import com.koron.housing.contract.bean.param.HousingContractBillParam;
import com.koron.housing.contract.bean.po.HousingContract;
import com.koron.housing.contract.bean.query.ContractQuery;
import com.koron.housing.contract.bean.vo.HousingContractVO;
import org.koron.ebs.mybatis.SessionFactory;

import java.util.List;

/**
 * 合同信息(HousingContract)表服务接口
 *
 * @author jzp
 * @since 2022-03-07 14:45:16
 */
public interface HousingContractService {

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    HousingContract getById(SessionFactory factory, String id);

    HousingContractDTO getDtoById(SessionFactory factory, String id);

    /**
     * 查询所有数据
     *
     * @param query 查询条件对象
     * @return 列表结果集
     */
    List<HousingContract> list(SessionFactory factory, ContractQuery query);

    List<HousingContractVO> listVo(SessionFactory factory, ContractQuery query);

    /**
     * 分页查询
     *
     * @param query 分页条件
     * @return 对象列表
     */
    default PageInfo<HousingContractVO> page(SessionFactory factory, PageQuery pageQuery, ContractQuery query) {
        PageHelper.startPage(pageQuery.getPage(), pageQuery.getPageSize(), pageQuery.getOrderBy());
        List<HousingContractVO> housingContractList = listVo(factory, query);
        return new PageInfo<>(housingContractList);
    }

    List<HousingContract> address(SessionFactory factory);
    List<HousingContract> village(SessionFactory factory);
    List<HousingContract> billCode(SessionFactory factory);
    List<HousingContract> tenantry(SessionFactory factory);

    /**
     * 新增数据
     *
     * @param housingContract 实例对象
     * @return 是否成功
     */
    boolean save(SessionFactory factory, HousingContract housingContract);

    boolean billSubmit(SessionFactory factory, HousingContractBillParam housingContractBillParam);

    /**
     * 修改数据
     *
     * @param housingContract 实例对象
     * @return 是否成功
     */
    boolean update(SessionFactory factory, HousingContract housingContract);

    boolean renewal(SessionFactory factory, HousingContract housingContract);

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    boolean deleteById(SessionFactory factory, String id);

}
